<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use think\Db;
class News extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function _initialize()
    {
        parent::_initialize();

        $param = $this->request->param();
        $lanmu = isset($param['lanmu'])?$param['lanmu']:1;
        $cid = isset($param['cid'])?$param['cid']:null;
        
        $erlist = $this->getContentByLang(Db::name('newstype')->where('status',$lanmu)->order('weigh','desc')->order('id','desc')->select());


        $this->lanmu = $lanmu;
        $this->cid = $cid;

        $this->view->assign('lanmu', $lanmu);
        $this->view->assign('cid', $cid);
        $this->view->assign('erlist', $erlist);

    }

    public function index()
    {
        $param = $this->request->param();
        $cid = $this->cid;
        $id = isset($param['id'])?$param['id']:null;

        $show = $this->getContentByLang(Db::name('newslist')->where('id',$id)->find());

        $this->view->assign('show', $show);
        return $this->view->fetch('show');
    }

    public function show()
    {
        $param = $this->request->param();
        $cid = $this->cid;
        $id = isset($param['id'])?$param['id']:null;

        $show = $this->getContentByLang(Db::name('newslist')->where('id',$id)->find());

        $this->view->assign('show', $show);
        return $this->view->fetch('show');
    }

}
